
var OddsObject = Class.create();
OddsObject.prototype = {
	initialize: function(objOdds, strID, intSumStake, flSumPayOff, flSumCommission){
		this.ID = strID;
		this.OData = objOdds;
		this.setPreWinData(intSumStake, flSumPayOff, flSumCommission);
	},

	setOddsData: function(objOdds, intSumStake, flSumPayOff, flSumCommission){
		this.OData = objOdds;
		this.setPreWinData(intSumStake, flSumPayOff, flSumCommission);
	},

	setPreWinData: function(intSumStake, flSumPayOff, flSumCommission){
		this.preRealWin = Math.round(intSumStake - (this.OData.tolRS - this.OData.tolSS) - (this.OData.tolRP - this.OData.tolSP) - flSumCommission);
		this.preWin = Math.round(intSumStake - (this.OData.tolS - this.OData.tolSS) - (this.OData.tolP - this.OData.tolSP) - flSumCommission);
	},

	toPlusMinusForm: function(isParlays){

		var strBTSite = objBTConfig.getBTSite(this.OData.BT);
		var strOddsTD_ID = "OddsTD" + strBTSite + "_" + this.OData.Num;
		var strNumTD_ID = "Num" + strBTSite + "_" + this.OData.Num;

		if($objDOM(strOddsTD_ID) == null)return;
		if($objDOM('OddsA'+this.OData.BT+'_'+this.OData.Num) == null){
			$objDOM(strOddsTD_ID).innerHTML = this.getPlusMinusForm(strOddsTD_ID, isParlays);

		}else{
			$objDOM('OddsA'+this.OData.BT+'_'+this.OData.Num).innerHTML = this.getOdds();
			$objDOM('Stake'+this.OData.BT+'_'+this.OData.Num).innerHTML = this.getStakeByIsReal().toString();
			if(this.getIsShowPreWin())$objDOM('PreWin'+this.OData.BT+'_'+this.OData.Num).innerHTML = this.getPreWinByIsReal().toString();
		}

		this.toAVOddsCount(strBTSite);

		if($objDOM(strNumTD_ID) != null)$objDOM(strNumTD_ID).className = (this.OData.isStop == "1")?"G_Con_TD_Dark":"G_Con_TD_Ball";
		$objDOM(strOddsTD_ID).className = (this.OData.isStop == "1")?"G_Con_TD_Dark":"G_Con_TD_Odds";
		return true;
	},

	toSortPlusMinusForm: function(intSortNo){
		var strBTSite = objBTConfig.getBTSite(this.OData.BT);
		var strNumTD_ID = "Num" + strBTSite + "_" + intSortNo;
		var strOddsTD_ID = "OddsTD" + strBTSite + "_" + intSortNo;
		setNumberForm(this.OData.BT, this.OData.Num, intSortNo, strBTSite);

		$objDOM(strOddsTD_ID).innerHTML = this.getPlusMinusForm(strOddsTD_ID, false);

		$objDOM(strNumTD_ID).className = (this.OData.isStop == "1")?"G_Con_TD_Dark":"G_Con_TD_Ball";
		if(PageConfig.SortType == 1){
			$objDOM(strOddsTD_ID).className = (this.OData.isStop == "1")?"G_Con_TD_Dark":"G_Con_TD_Odds_Sort";
		}else{
			$objDOM(strOddsTD_ID).className = (this.OData.isStop == "1")?"G_Con_TD_Dark":"G_Con_TD_Odds";
		}
		this.toAVOddsCount(strBTSite);
		return true;
	},

	toAVOddsCount: function(strBTSite){
		if(objBTConfig.getAVOdds(this.OData.BT) == 0)return;

		var strAVOddsTD_ID = "AVOddsNum" + strBTSite + "_" + this.OData.Num;
		var flOdds = 0;

		if(PageConfig.isShowAVOdds == "Y" && $objDOM(strAVOddsTD_ID) != null){
			if(parseFloat(this.OData.tolS) > 0.01){
				flOdds = (this.getPayOffByIsReal() + this.getStakeByIsReal() + this.getCommisionByIsReal() - this.getStakeByIsReal()*arrCommion[this.OData.BT]) / this.getStakeByIsReal();
				flOdds = Math.round(flOdds*100) / 100;
			}
			$objDOM(strAVOddsTD_ID).innerHTML = flOdds;
		}	
	},

	getPlusMinusForm: function(strOddsTD_ID, isParlays){

		if(isParlays){
			var strCon = "<a class='G_Con_Odds' href='JavaScript: void(0)' id='SOddsA"+this.OData.BT+"_"+this.OData.Num+"'>"+this.getOdds()+"</a><br />";
			strCon += "<a class='G_Con_Bet' href='JavaScript: void(0)' onclick='getWagerData( \""+this.ID+"\", event)' id='SStake"+this.OData.BT+"_"+this.OData.Num+"'>"+Math.round(this.OData.tolS).toString()+"</a>";

		}else if(!this.getIsShowPlusMinusForm()){
			var strCon = "<a class='G_Con_Odds' href='JavaScript:ShowOddsLayer(\""+this.ID+"\", \""+strOddsTD_ID+"\")' id='SOddsA"+this.OData.BT+"_"+this.OData.Num+"'>"+this.getOdds()+"</a>";

		}else{
			var strCon = "<table width='99%' border='0' cellspacing='0' cellpadding='0'><tr><td onclick='PlusMinusOdds(1, \""+this.ID+"\");' class='G_Con_Odds_Plus'>+</td>";
			strCon += "<td align='center'><a class='G_Con_Odds' href='JavaScript:ShowOddsLayer(\""+this.ID+"\", \""+strOddsTD_ID+"\")' id='SOddsA"+this.OData.BT+"_"+this.OData.Num+"'>"+this.getOdds()+"</a></td>";

			strCon += "<td onclick='PlusMinusOdds(0, \""+this.ID+"\");' class='G_Con_Odds_Minus'>-</td></tr></table>";
			strCon += "<a class='G_Con_Bet' href='JavaScript: void(0)' onclick='getWagerData( \""+this.ID+"\", event)' id='SStake"+this.OData.BT+"_"+this.OData.Num+"'>"+this.getStakeByIsReal().toString()+"</a>";

			if(this.getIsShowPreWin()){
				var strClass = (this.getPreWinByIsReal() > 0)?"G_Con_Result_Win":"G_Con_Result_Lose";
				strCon += "<br /><a class='"+strClass+"' id='SPreWin"+this.OData.BT+"_"+this.OData.Num+"'>"+this.getPreWinByIsReal().toString()+"</a>";
			}else{
				strCon += "<br /> &nbsp;";
			}

			/*if(PageConfig.isShowSpAllWin && objBTConfig.getShowAllWin(this.OData.BT) == 1){
				strCon += "<br /><a class='"+strClass+"'>"+Math.round(this.getAllWinByIsReal())+"</a>";
			}*/
		}
		return strCon;
	},

	setAllWin: function(){
		if(!PageConfig.isShowSpAllWin)return;
		if(objBTConfig.getShowAllWin(this.OData.BT) != 1)return;
		if(PageConfig.isRealShow == 1){
			this.AllRealWin = getSPNumAllWin(this.OData.Num) + this.preRealWin;
		}else{
			this.AllWin = getSPNumAllWin(this.OData.Num) + this.preWin;
		}
	},

	getOdds: function(){
		return Math.round((this.OData.Odds + objBTConfig.getBTGLine(this.OData.BT, this.OData.Num))*1000)/1000;
	},

	getAllWinByIsReal: function(){
		var intOther = objBTConfig.getOtherPreWin(this.OData.BT, this.OData.Num);
		var flWin = (PageConfig.isRealShow == 1)?this.AllRealWin:this.AllWin;
		return Math.round(flWin + intOther);
	},

	getStakeByIsReal: function(){
		var intOther = objBTConfig.getOtherStake(this.OData.BT, this.OData.Num);
		var flS = (PageConfig.isRealShow == 1)?this.OData.tolRS:this.OData.tolS;
		return Math.round(flS + intOther);
	},

	getPayOffByIsReal: function(){
		var intOther = objBTConfig.getOtherPayOff(this.OData.BT, this.OData.Num);
		var flP = (PageConfig.isRealShow == 1)?this.OData.tolRP:this.OData.tolP;
		return Math.round(flP + intOther);
	},

	getCommisionByIsReal: function(){
		var intOther = objBTConfig.getOtherCommision(this.OData.BT, this.OData.Num);
		var flC = (PageConfig.isRealShow == 1)?(this.OData.tolC+intOther):0;
		return Math.round(flC);
	},

	getPreWinByIsReal: function(){
		if(PageConfig.isShowSpAllWin && objBTConfig.getShowAllWin(this.OData.BT) == 1)return this.getAllWinByIsReal();
		if(objBTConfig.getIsShowSpecialPreWin(this.OData.BT))return objBTConfig.getSpecialPreWin(this);

		var intOther = objBTConfig.getOtherPreWin(this.OData.BT, this.OData.Num);
		var flWin = (PageConfig.isRealShow == 1)?this.preRealWin:this.preWin;
		return Math.round(flWin + intOther);
	},

	getIsShowPreWin: function(){
		return (objBTConfig.getIsNotShowPreWinForm(this.OData.BT) == 1)?false:true;
	},

	getIsShowPlusMinusForm: function(){
		return (objBTConfig.getIsNotShowPlusMinusForm(this.OData.BT) == 1)?false:true;
	}
};

//載入號碼
function setNumberForm(intBT, intNum, intSortNo, strBTSite){
	var strNumSite = "Num" + strBTSite + "_" + intSortNo.toString();
	var strAVOddsSite = "Num" + strBTSite + "_" + intNum.toString();

	$objDOM(strNumSite).innerHTML = "<a href=\"JavaScript:StopBet(" + intBT.toString() + ", " + intNum.toString() + ")\" class=\"G_Con_Numer_" + PageConfig.BColor_Value[ PageConfig.BColor_Index[intNum - 1] ] + "\">" + ((intNum < 10)?"0" + intNum.toString() : intNum.toString()) + "</a>";

	if(PageConfig.isShowAVOdds == "Y") $objDOM(strNumSite).innerHTML += "<br /><a id=\"AVOdds" + strAVOddsSite + "\"></a>";
}

//輸贏排序
function PreWinSorter(objOdds1, objOdds2){
	return (objOdds2.getPreWinByIsReal() - objOdds1.getPreWinByIsReal())*PageConfig.SortPlus;
}

//注額排序
function StakeSorter(objOdds1, objOdds2){
	return (objOdds1.getStakeByIsReal() - objOdds2.getStakeByIsReal())*PageConfig.SortPlus;
}

function changEmergency(){
	$objDOM("EmergencyLink").innerHTML = (PageConfig.isEmergency == 0)?strEmergencyOff:strEmergencyOpen;
	$objDOM("EmergencyLink").className = (PageConfig.isEmergency == 0)?"G_Con_Emergency_Off":"G_Con_Emergency_On";
}

function takeEmergency(){
	with(document.getDataForm){
		op.value = "OffAllWager";
		if(PageConfig.isEmergency == 0)if(!confirm(strEmergencyOffAlert))return;
		intEmergency.value = (PageConfig.isEmergency == 0)?"1":"0";
		submit();
	}
}
/*
function changSortClass(){
	$objDOM("TenSortLink").innerHTML = (PageConfig.SortPlus == -1)?strTenLoseSort:strTenWinSort;
	$objDOM("TenSortTD").className = (PageConfig.SortPlus == -1)?"G_Con_SortLoseTD":"G_Con_SortWinTD";
}

function changSort(){
	PageConfig.SortPlus *= -1;
	changSortClass();
	RefreshType();
}*/

function setSortType(intType){
	PageConfig.SortType = intType*1;
	RefreshType();
}

//開放停押，所有號碼和項目
function StopAllBet(isStop, strBT, strNum){
	with(document.getDataForm){
		op.value = "StopBet";
		isStopBet.value = isStop;
		Bet_Type.value = strBT;
		LottoNumber.value = strNum;
		submit();
	}
}

//給選擇樂透種類下拉選單用
function LottoSelect(){
	document.OddsListForm.action = getLottoOperateLink(document.OddsListForm.LottoID.value*1, "Operate");
	document.OddsListForm.submit();
}

//顯示賠率視窗
function ShowOddsLayer(strOddsID, strOddsTD_ID){
	var objO = objOddsData[strOddsID];

	with(document.OddsLayer){
		op.value = "OddsUpdate";
		GambleID.value = objO.OData.GID;
		Bet_Type.value = objO.OData.BT;
		intNumber.value = objO.OData.Num;
		//isSpecial.value = intSpecial;
		Odds.value = objO.OData.Odds;
	}

	$objDOM("odds_win").style.top = $objDOM(strOddsTD_ID).offsetTop + $objDOM(strOddsTD_ID).clientHeight + 56;
	$objDOM("odds_win").style.left = $objDOM(strOddsTD_ID).offsetLeft;
	$objDOM("odds_win").style.display = "block";
	close_WagerWin();
}

//關閉賠率視窗
function close_OddsWin(){
	$objDOM("odds_win").style.display = "none";
}

//關閉明細視窗
function close_WagerWin(){
	$objDOM("wager_win").style.display = "none";
}

//批次用賠率差調整賠率
function PlusMinusOdds(isAdd, strOddsID){
	var objO = objOddsData[strOddsID];
	var intBT = objO.OData.BT*1;
	var intNum = objO.OData.Num;
	var flOdds = objO.OData.Odds*1;

	with(document.OddsLayer){
		op.value = "OddsUpdate";
		GapOdds.value = ((isAdd == 1)?"":"-") + arrJumpOdds[intBT];
		Odds.value = flOdds + parseFloat(GapOdds.value);
		intNumber.value = intNum;
		GambleID.value = document.getDataForm.GambleID.value;
		Bet_Type.value = intBT;
		submit();
	}
}

//開放停押，只單一號碼或項目
function StopBet(intBT, intNum){
	var strID = intBT.toString() + "_" + intNum.toString();
	var objO = objOddsData[strID];

	with(document.getDataForm){
		isStopBet.value = (objO.OData.isStop == "0")?1:0;
		op.value = "StopBet";
		Bet_Type.value = intBT.toString();
		LottoNumber.value = intNum.toString();
		switch(intBT){
			case 2:
			case 3:
			case 5:
			case 6:
			case 16:
				LottoNumber.value = "0,1";
				break;
		}
		submit();
	}
}

//送出下注明細連結
function setWagerDataLink(strDocLoc, e){
	var strX = 0, strY = 0;
	if (IE) { // grab the x-y pos.s if browser is IE
		strX = event.clientX + document.body.scrollLeft;
		strY = event.clientY + document.body.scrollTop + 20;
	} else {  // grab the x-y pos.s if browser is NS
		strX = e.pageX;
		strY = e.pageY + 20;
	}  

	if($objDOM("OddsTable").clientWidth < strX + 483){
		strX = strX - 487;
	}

	createXMLHttpRequest();
	xmlHttp.onreadystatechange = function(){ handleWagerDataChange(strX, strY) };
	xmlHttp.open("GET", strDocLoc, true);
	xmlHttp.send(null);
}

function handleWagerDataChange(strX, strY){
	if(xmlHttp.readyState == 4){
		if(xmlHttp.status == 200){
			var xmlDoc = xmlHttp.responseXML;
			
			if(xmlDoc.getElementsByTagName("root")[0] == null){
				alert("No Data");
				return;
			}

			showWagerData(xmlDoc, strX, strY);
			return;
		}
	}
}

//顯示下注明細圖層
function showWagerData(xmlDoc, strX, strY){
	var i = 0;
	var objWTable = $objDOM("WagerTable");
	var objWLayer = $objDOM("WagerLayer");

	$objDOM("wager_win").style.top = strY;
	$objDOM("wager_win").style.left = strX;
	$objDOM("wager_win").style.display = "block";

	with(objWTable)	{
		while(rows.length > 1)	deleteRow(rows.length - 1);

		for (i = 0; i < xmlDoc.getElementsByTagName("WagerData").length; i++) {
			newTR = insertRow();
			newTR.className = "Account_Con_BG";
			with(newTR){
				var intCellNo = 0;
				var objWagerItem = xmlDoc.getElementsByTagName("WagerData")[i];

				newTD = insertCell(intCellNo);
				newTD.align = "left";
				newTD.innerHTML = objWagerItem.getElementsByTagName("BetDate")[0].firstChild.nodeValue + "&nbsp;" + objWagerItem.getElementsByTagName("BetTime")[0].firstChild.nodeValue + "<br />" + objWagerItem.getElementsByTagName("BetNo")[0].firstChild.nodeValue;
				intCellNo++;

				newTD = insertCell(intCellNo);
				newTD.align = "right";
				newTD.innerHTML = objWagerItem.getElementsByTagName("Account")[0].firstChild.nodeValue;
				intCellNo++;

				newTD = insertCell(intCellNo);
				newTD.innerHTML = objWagerItem.getElementsByTagName("Content")[0].firstChild.nodeValue;
				intCellNo++;

				newTD = insertCell(intCellNo);
				newTD.align = "right";
				if(objWagerItem.getElementsByTagName("OneStake")[0].firstChild != null){
					newTD.innerHTML = objWagerItem.getElementsByTagName("OneStake")[0].firstChild.nodeValue + "<br /><br />" + objWagerItem.getElementsByTagName("Stake")[0].firstChild.nodeValue;
				}else{
					newTD.innerHTML = objWagerItem.getElementsByTagName("Stake")[0].firstChild.nodeValue;
				}
				intCellNo++;

				newTD = insertCell(intCellNo);
				newTD.align = "right";
				newTD.innerHTML = objWagerItem.getElementsByTagName("Income")[0].firstChild.nodeValue;
			}
		}
	}	

	objWLayer.style.height = (objWTable.clientHeight > 300)?300:objWTable.clientHeight;
}


//顯示即時注單明細視窗
function getNowWagerList(){
	window.open("showblack.php?LID=" + PageConfig.LottoID,"BlackWindow_" + PageConfig.HTTP_HOST,"toolbar=no,width=540,height=400,top=0,left=0,directories=no,status=no,scrollbars=yes,resizable=yes,menubar=no");
}

//顯示即時注單明細視窗
function getNowWagerItemSort(){
	window.open("/k_admin/Account/WagerItemSort.php?GID=" + PageConfig.GambleID + "&RealShow=" + PageConfig.isRealShow,"WagerItemSort_" + PageConfig.HTTP_HOST,"toolbar=no,width=1070,height=500,top=0,left=0,directories=no,status=no,scrollbars=yes,resizable=yes,menubar=no");
}

/*--判斷特定欄位值是否有填--*/
function isEmpty(str) { 
	for (var i = 0; i < str.length; i++)
		if (" " != str.charAt(i))return false; 
		return true; 
}

//檢查賠率值
function checkOddsValue(strOdds, flMaxOdds){
	if(isEmpty(strOdds)){
		alert(strOddsIsEmpty);
		return false;
	}else if(isNaN(strOdds)){
		alert(strOddsIsString);
		return false;
	}else if(parseFloat(strOdds) <= 0){
		alert(strOddsUnderZero);
		return false;
	}else if(parseFloat(strOdds) > flMaxOdds){
		alert(strOddsOverMaxOdds + flMaxOdds);
		return false;
	}
	return true;
}


//轉換 Odds 陣列成 物件
function setOddsObject(){
	var intBT = 0, strNum = "", strID = "", intSumStake = 0, flSumPayOff = 0, flSumCommission = 0, intNum = 0, objGame;
	var arrUpBT = PageConfig.UpdateBetType.split(",");

	setAllSumStake();

	for(var i = 0; i < arrUpBT.length; i++){
		intBT = arrUpBT[i]*1;
		for(var intNo in arrGame[intBT]){
			objGame = arrGame[intBT][intNo];
			strNum = objGame.Num;

			if(typeof(arrSumStake[intBT]) == "number"){
				intSumStake = arrSumStake[intBT];
				flSumPayOff = arrSumPayOff[intBT];
				flSumCommission = arrSumCommission[intBT];
			}else{
				intNum = getSumNumber(intBT, intNo);
				intSumStake = arrSumStake[intBT][intNum];
				flSumPayOff = arrSumPayOff[intBT][intNum];
				flSumCommission = arrSumCommission[intBT][intNum];
			}
			//return;

			strID = intBT.toString() + "_" + intNo;
			if(null == objOddsData[strID]){
				objOddsData[strID] = new OddsObject (objGame, strID, intSumStake, flSumPayOff, flSumCommission);
				//arrGame[intBT][intNo].isSet = true;
			}else{
				objOddsData[strID].setOddsData(objGame, intSumStake, flSumPayOff, flSumCommission);
			}
		}
	}
	showOddsObject();
}

//顯示 Odds 物件 至賠率表
function showOddsObject(){
	var intBT = 0, strID = "", arrSort = [], flMaxPayOff = 0;
	var arrNowBT = getChangeNowBetType();

	for(var i = 0; i < arrNowBT.length; i++){
		flMaxPayOff = 0;
		arrSort = [];
		intBT = arrNowBT[i]*1;

		for(var intNo in arrGame[intBT]){
			strID = intBT.toString() + "_" + intNo;
			objOddsData[strID].setAllWin();

			if(flMaxPayOff > objOddsData[strID].getPreWinByIsReal())flMaxPayOff = objOddsData[strID].getPreWinByIsReal();

			if(objBTConfig.getBTSorter(intBT) == 1){
				arrSort[arrSort.length] = objOddsData[strID];
			}else{
				objOddsData[strID].toPlusMinusForm(PageConfig.NowBTIsParlays);
			}
		} // for(var intNo = 0; intNo < arrGame[intBT].length; intNo++){ //

		setSortOddsToTable(intBT, arrSort);
		setMaxLoseToTable(intBT, flMaxPayOff);
	} // for(var i = 0; i <= arrBT.length; i++){ //
}


//載入排行榜
function setSortOddsToTable(intBT, arrSort){
	if(arrSort.length == 0)return true;

	if(PageConfig.SortType == 1){
		if(objBTConfig.getBTSortType(intBT) == 1){
			arrSort.sort(PreWinSorter);
		}else{
			arrSort.sort(StakeSorter);
		}
	}
	for(var intNo = 0; intNo < arrSort.length; intNo++){
		arrSort[intNo].toSortPlusMinusForm(intNo + 1);
	}
}

//載入最大負值 和 總注額
function setMaxLoseToTable(intBT, flMaxPayOff){
	var strBTSite = objBTConfig.getBTSite(intBT);

	if($objDOM("SumStakeValue" + strBTSite) != null){
		$objDOM("SumStakeValue" + strBTSite).innerHTML = Math.round(arrSumStake[intBT] + objBTConfig.getOtherSumStake(intBT));
	}

	if($objDOM("MaxLose" + strBTSite) != null){
		$objDOM("MaxLose" + strBTSite).innerHTML = Math.round(flMaxPayOff);
	}
}

//初始化賠率表
function iniOddsLayer(strBT){
	var strOddsLayer = "Layer" + strBT.toString();
	var strListStatus = "T" + strBT.toString();

	if(null != objListStatus[strListStatus])$objDOM("ListStatus").innerHTML = objListStatus[strListStatus];
	if(null == OddsLayer[strOddsLayer])return false;
	if(PageConfig.NowOddsLayer == strOddsLayer)return true;

	PageConfig.NowOddsLayer = strOddsLayer;
	$objDOM("BetList").innerHTML = OddsLayer[strOddsLayer];
	setOddsNumber(strBT*1);
	return true;
}

//重整方式
function RefreshType(){
	if(PageConfig.isEmergency == 1)alert(strOnEmergency);
	with(document.getDataForm){
		if(op.value == "StartGame"){
			StartGame();
		}else{
			GetOdds();
		}
	}
}

//定時重整
function RClock(i){
	if (RSeconds == 0){
		RefreshType();
		RSeconds = i;
	}
	RSeconds --;
	if($objDOM("RSec"))$objDOM("RSec").innerHTML = RSeconds;
}

//顯示虛貨，實貨方式
function ChangeReal(obj){
	PageConfig.isRealShow = obj.value*1;
	RefreshType();
}

//選擇定時時間
function ChangeRefreshSec(obj){
	if(AutoRefreshID > 0)clearInterval(AutoRefreshID);
	AutoRefreshID = setInterval("RClock("+obj.value+")",1000);
}

//取得賠率
function GetOdds(){
	with(document.getDataForm){
		op.value = "GetOdds";
		NewUpdateTime.value = PageConfig.NewUpdateTime;
		submit();
	}
}

//顯示以開獎表格
function StartGame(){
	var KGame = new Array(), strGID = "", strBID = "";
	close_WagerWin();
	OnOff_QuickTable(0);

	$objDOM("BetList").innerHTML = OddsLayer.LayerStart;
	$objDOM("ListStatus").innerHTML = objListStatus.TSG;
	PageConfig.NowOddsLayer = "LayerStart";

	var strDocLoc="getWagerStart.xml.php?LottoID="+PageConfig.LottoID+"&GambleID="+PageConfig.GambleID;
	createXMLHttpRequest();
	xmlHttp.onreadystatechange = function(){ handleStartGameChange() };
	xmlHttp.open("GET", strDocLoc, true);
	xmlHttp.send(null);
}

//送出下注明細連結
function handleStartGameChange(){
	if(xmlHttp.readyState != 4)return;
	if(xmlHttp.status != 200)return;
	var xmlDoc = xmlHttp.responseXML;
			
	if(xmlDoc.getElementsByTagName("WagerData")[0] == null){
		alert("No Data");
		return;
	}

	var objOTable = $objDOM("OddsTable");
	with(objOTable)	{
		while(rows.length > 1)	deleteRow(rows.length - 1);

		for (i = 0; i < xmlDoc.getElementsByTagName("WagerData").length; i++) {
			newTR = insertRow();
			newTR.className = "G_Con_TR";
			with(newTR){
				var intCellNo = 0;
				var objWagerItem = xmlDoc.getElementsByTagName("WagerData")[i];

				newTD = insertCell(intCellNo);
				newTD.innerHTML = objWagerItem.getElementsByTagName("GameDate")[0].firstChild.nodeValue + "&nbsp;" + objWagerItem.getElementsByTagName("GameTime")[0].firstChild.nodeValue;
				intCellNo++;

				newTD = insertCell(intCellNo);
				newTD.innerHTML = objWagerItem.getElementsByTagName("GameNo")[0].firstChild.nodeValue;
				intCellNo++;

				newTD = insertCell(intCellNo);
				newTD.align = "left";
				newTD.innerHTML = objWagerItem.getElementsByTagName("BetType")[0].firstChild.nodeValue;
				intCellNo++;

				strGID = objWagerItem.getElementsByTagName("GambleID")[0].firstChild.nodeValue;
				strBID = objWagerItem.getElementsByTagName("BID")[0].firstChild.nodeValue;

				newTD = insertCell(intCellNo);
				newTD.align = "left";
				newTD.id = "OddsTD"+strBID;
				if(PageConfig.isRealShow == "1"){
					newTD.innerHTML = "<a class=\"G_Con_Bet_Start\" href=\"JavaScript:void(0)\" onclick=\"getStartWagerData("+strBID+", event)\">"+objWagerItem.getElementsByTagName("CountNo")[0].firstChild.nodeValue+"&nbsp;/&nbsp;"+objWagerItem.getElementsByTagName("RateMemStake")[0].firstChild.nodeValue+"</a>";
				}else{
					newTD.innerHTML = "<a class=\"G_Con_Bet_Start\" href=\"JavaScript:void(0)\" onclick=\"getStartWagerData("+strBID+", event)\">"+objWagerItem.getElementsByTagName("CountNo")[0].firstChild.nodeValue+"&nbsp;/&nbsp;"+objWagerItem.getElementsByTagName("AllMemStake")[0].firstChild.nodeValue+"</a>";
				}
				intCellNo++;
			}
		}
	}
}

//取得下注明細
function getStartWagerData(strBT, event) {
	var strDocLoc="getWager.xml.php?GambleID="+PageConfig.GambleID+"&Bet_Type="+strBT+"&Number=-1&isStop=0&isRealShow="+PageConfig.isRealShow;

	setWagerDataLink(strDocLoc, event);
}

//更改分盤顯示
function ChangeGambleType(obj){
	with(document.getDataForm){
		PageConfig.GLine = obj.value*1;
		RefreshType();
	}
}